package com.jixiang.dictionary.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jixiang.model.common.dtos.ResponseResult;
import com.jixiang.model.dictionary.entity.DsFile;
import com.jixiang.dictionary.service.DsFileService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;

/**
 * 图片(DsFile)表控制层
 *
 * @author makejava
 * @since 2023-10-17 00:13:41
 */
@RestController
@RequestMapping("file")
public class DsFileController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private DsFileService dsFileService;

    @ApiOperation("图片文件上传日志保存")
    @PostMapping("/saveFileLog")
    public ResponseResult saveFileLog(Long userId, String url, String type, String description) {
        Boolean flag = dsFileService.saveFileLog(userId,url,type,description);
        return ResponseResult.okResult("文件上传日志保存成功");
    }

    @ApiOperation("管理端用户上传图片")
    @PostMapping("/UploadImg")
    public ResponseResult UploadImg(MultipartFile file) throws IOException {
        return dsFileService.UploadImg(file);
    }


    @ApiOperation("管理端用户删除上传图片")
    @PostMapping("/UploadImgDel")
    public ResponseResult UploadImgDel(@RequestParam(required = true)String url) {
        return dsFileService.UploadImgDel(url);
    }

    @ApiOperation("微信端用户上传头像图片")
    @PostMapping("/WxUploadIconImg")
    public ResponseResult WxUploadIconImg(MultipartFile file,@RequestParam String oldImage) throws IOException {
        return dsFileService.WxUploadIconImg(file,oldImage);
    }


}

